/*********************************************************************
* Here are the global definitions used by all the subroutines        *
*                                                                    *       
*********************************************************************/

#ifdef FIRST_MACRO_2D_H
#else 
#define FIRST_MACRO_2D_H

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <memory.h>
/* #include <curses.h> */
/* #include <ncurses.h> */
#include <time.h>       
#include <string.h>    /* functions to get data via web (stadin) */
/* #include <rfftw.h>  */    /*  needed for taking fft in derivs and main */
#include <mpi.h> 
#ifdef SV
#include "java_ser.h" 
#endif
#ifdef SDF
#include "sdf.h"
#endif

#define MPI
/* #undef MPI */

#define DEBUG
#undef DEBUG
//#define DEBUG_INPUT
//#define DEBUG_INIDAT 
//#define DEBUG_ADISCO 
//#define DEBUG_MPI 
//#define DEBUG_EQN


//#define DISSIPATION
#undef DISSIPATION

/* EXCISION: WARNING excision in derivatives alter the fields from  */
/*           we take derivatives of, so use some dummy variable     */

#define EXCISION
#undef EXCISION

/* To make a mask for the excision region in inidat.c */

#define MAKE_MASK
#undef MAKE_MASK

/* different method to solve the equations */

#define PROJECTION
//#undef PROJECTION

#define ENERGY

/* -----------> The number of grids and sides <------------------------ */

#define DIM 2
#define N_GRIDS 6
#define N_SIDES 2

/* -----------> The number of grid points <------------------------ */

/* Use odd numbers to get factor correct */

/* What follows is defined at input.c */

/* #define N_GRIDPOINTS_1 201 */
/* #define N_GRIDPOINTS_2 201 */

/* #define N_GRIDPOINTS_1_INITIAL 0 */
/* #define N_GRIDPOINTS_2_INITIAL 0 */

/* #define N_GRIDPOINTS_1_FINAL N_GRIDPOINTS_1 */
/* #define N_GRIDPOINTS_2_FINAL N_GRIDPOINTS_2 */


/* -----------> The excision region <------------------------ */

/* Excision region is given by 3 grid intervals which are the   */
/* numbres of points to the right (and left) which are take out */
/* starting form the middle of the grid.                        */
/* So, the left boundary point will be at:                      */
/* (N_GRIDPOINTS_1-1)/2 - N_GRIDPOINTS_1_EXC                    */
/* and the right boundary point will be at:                     */
/* (N_GRIDPOINTS_1-1)/2 + N_GRIDPOINTS_1_EXC                    */
/* If m=1 use 1 with 51, 2 with 101                             */
 
/* #ifdef EXCISION */

/* #define N_GRIDPOINTS_1_EXC 8 */
/* #define N_GRIDPOINTS_2_EXC 8 */

/* #endif */

/*------------------------------------------------------------*/

#define IND_2(i,j)	( ( (i)  *  (n_gridpts_2))  + ( (j) ))


#define GRD_IND [IND_2(grid_ind1,grid_ind2)]


/* ----------------> The number of fields <------------------------ */

/* That is the number of variables that enter the system            */

#define N_FIELDS 3

/* The name of the fields */

#define M_A 0      
#define M_B 1
#define M_C 2

#ifdef DISSIPATION

#define N_DERIVS 15

#define D_X_M_A 0        
#define D_Y_M_A 1       
#define DD_X_M_A 2       
#define DD_Y_M_A 3 
#define DISS_M_A 4
#define D_X_M_B 5        
#define D_Y_M_B 6       
#define DD_X_M_B 7       
#define DD_Y_M_B 8 
#define DISS_M_B 9
#define D_X_M_C 10        
#define D_Y_M_C 11       
#define DD_X_M_C 12       
#define DD_Y_M_C 13 
#define DISS_M_C 14
#else

#define N_DERIVS 12


#define D_X_M_A 0        
#define D_Y_M_A 1       
#define DD_X_M_A 2       
#define DD_Y_M_A 3 
#define D_X_M_B 4        
#define D_Y_M_B 5       
#define DD_X_M_B 6       
#define DD_Y_M_B 7 
#define D_X_M_C 8        
#define D_Y_M_C 9       
#define DD_X_M_C 10       
#define DD_Y_M_C 11 

#endif

/* Auxiliary Fields */

#define N_AUX 9


#define G_UP_XX 0
#define G_UP_YY 1
#define G_UP_XY 2
#define SWAP_X_X  3
#define SWAP_X_Y  4
#define SWAP_Y_X  5
#define SWAP_Y_Y  6
#define SWAP_Z_X  7
#define SWAP_Z_Y  8


#define N_FIELDS_MPI 6

#define PSI_X 3
#define PSI_Y 4
#define PSI_Z 5



/* That is the number of gridpoints times the number of fields      */

/* #define N_GRIDS ((N_GRIDPOINTS_1)*(N_GRIDPOINTS_2)) */
/* #define N_T
 * OTAL (((N_GRIDPOINTS_1)*(N_GRIDPOINTS_2))*(N_FIELDS)) */


/* The total number of plots (used in struct plot) */

#define N_PLOTS 3

/* The gridpoints for plots, usually a fraction of N_GRIDPOINTS */


/* #define FACTOR_1 1 */ /* Choose it so that the plot is about 20 points */ 
/* #define FACTOR_2 1 */ /* Choose it so that the plot is about 20 points */ 

/* #define N_GRID_PLOT_PTS_1 (((N_GRIDPOINTS_1-1) / FACTOR_1) +1) */
/* #define N_GRID_PLOT_PTS_2 (((N_GRIDPOINTS_2-1) / FACTOR_2) +1) */
/* #define N_GRIDS_PLOT ((N_GRID_PLOT_PTS_1)*(N_GRID_PLOT_PTS_2)) */

/* #define IND_2_PLOT_F(i,j)	( ( (i) * (n_gridpts_plot_2) )  +  (j) ) */


/* The number PI */

#ifdef PI

#undef PI
#endif
#define PI 3.141592653589793238462643

/* --------------------------------------------------------------*/

/* The size of variables */

#define FLOAT double


/* -------------------- FUNCTIONS -------------------------------*/

/* different types of plotting routines, could be:
   graph(er-3d), map(le)3, map(le)5, mtv, idl, sv, fsv or gen 
   this are changes on the type of file where 
   the routine is defined */


#define SDF  /* use to change the plot structure */
/* #define MID_WRITE */ /* routine to put the coordinate point in the sdf files */
#undef MID_WRITE
#define OUT_FULL /* routine to put only the data in sdf files */
/* #undef OUT_FULL */ /* routine to put only the data in sdf files */
#undef SV
#undef NETCDF

#ifdef SDF
#define ADISCO adisco_sdf_2d
#endif

#ifdef NETCDF
#define ADISCO adisco_netcdf_2d
#endif

#ifdef SV
#define ADISCO adisco_fsv_2d   /* #define ADISCO adisco_sv_3d */
#endif


/* -----------------------------------------------------------------*/


/* input output definitions */

#undef WEB_INPUT              /* define only one of these two */
#define FILE_INPUT

#ifdef WEB_INPUT
#define OUT_PUT stdout
#endif
#ifdef FILE_INPUT
#define OUT_PUT file_data_ptr // (*plot_par).input_data_file_ptr // file_data_ptr
#endif

#define INPUT_FUNCTION heat_2d_input

/* used in routines to get data from the web */
#define MAX_ENTRIES 400
#define MAX_ENTRY 200

/* To print the values of some macros */
/* Warning: only use where OUT_PUT is properly defined */

#define Strg(x) #x
#define PRINT_MACRO_VALUE(x) fprintf(OUT_PUT,"<li> Using %s = %s  </br>\n",#x,Strg(x));
#define GET_MACRO_VALUE(x)   sprintf(macro_value_strg,"%s",Strg(x))

/* ----------------------- structures -------------------------*/

#define GRID_PAR grid_2d         /* grid parameters */
#define PLOT_PAR plot_2d         /* ploting parameters */
#define INI_PAR heat_ini_par_2d  /* where initial data parameters are stored */
#define FUNCTION_PAR heat_par_2d /* equation parameters */


/* other structures */





/* -----------------------------------------------------------------*/

/* different functions for the integrator, here goes
   most of the physical input */

#define FF heat_2d_eq

/* different arguments for the function FF */

#define FF_ARG struct grid_2d *grid_2d, struct field_array *fields, struct field_array *derivs, struct FUNCTION_PAR *function_par
#define FF_ARG_DUMMY struct GRID_PAR *, struct field_array *, struct field_array *, struct FUNCTION_PAR *

/* different functions to take derivatives derivQ_2d, derivQ_3_2d, derivD, derivQQ, derivS_2d, deriv_strand_third_order_boundaries_sixth_interior_2d, deriv_strand_fourth_order_boundaries_eight_interior_2d, etc */

//#define DERIV deriv_strand_fourth_order_boundaries_eight_interior_2d
//#define DERIV deriv_strand_third_order_boundaries_sixth_interior_2d
#define DERIV derivQ_2d

#define NON_OPTIMIZED_EIGHT_ORDER_OPERATOR
#undef NON_OPTIMIZED_EIGHT_ORDER_OPERATOR

#define OPTIMIZED_EIGHT_ORDER_OPERATOR
//#undef OPTIMIZED_EIGHT_ORDER_OPERATOR



/* different functions to implement dissipation, diss_S_2d, diss_S0_2d, diss_CNG_2d, etc */

#ifdef DISSIPATION
//#define DISS diss_KO8_2d
#define DISS diss_KO6_2d
#endif

/* -----------------------------------------------------------------*/


/* different runge-kutta routines */

#define RKX rkc

 


/* -----------------------------------------------------------------*/

#endif
